import {
  getFreqScopes,
  addFreqScope,
  updateFreqScope,
  removeFreqScope,
  getFreqBands,
  addFreqBand,
  removeFreqBand,
  getAntennaFactors,
  addAntennaFactory,
  updateAntennaFactory,
  removeAntennaFactory,
  getAntennaFactorResults,
  addAntennaFactorResult,
  removeAntennaFactorResult,
  getReferenceLines,
  getCableLines,
  addLine,
  removeLine,
  getLineCalResults,
  updateLine,
  getCreateLineParams,
  getPositionCalInfos,
  addPosition,
  removePositionCal,
  updatePositionCal,
  getCreatePositionParams,
  getPositionCalResults
} from "../api/adjust/index";
import type { ConfigParams } from "../api/adjust/index.d";
export type TypeKeys = "freqscope" | "antennafactor" | "lineinfo" | "positioninfo";

export const apiMap = {
  freqscope: {
    list: getFreqScopes,
    add: addFreqScope,
    edit: updateFreqScope,
    remove: removeFreqScope,
    resultList: getFreqBands,
    addResult: addFreqBand,
    removeResult: removeFreqBand,
    removeKey: "freqScopeId",
    addKey: "freqScope",
    resultListKey: "freqScopeId",
    addResultKey: "freqBand",
    addResultCaseIdKey: "freqScopeId",
    removeResultKey: "freqBandId"
  }, // 频段列表
  antennafactor: {
    list: getAntennaFactors,
    add: addAntennaFactory,
    edit: updateAntennaFactory,
    remove: removeAntennaFactory,
    resultList: getAntennaFactorResults,
    addResult: addAntennaFactorResult,
    removeResult: removeAntennaFactorResult,
    removeKey: "anttennaFactorId",
    addKey: "antennaFactorInfo",
    resultListKey: "antennaFactorId",
    addResultKey: "antennaFactorResult",
    addResultCaseIdKey: "antennaFactorId",
    removeResultKey: "antennaFactorResultId"
  }, // 天线因子
  lineinfo: {
    getListApi: (type: string) => {
      return {
        Reference: getReferenceLines,
        Cable: getCableLines
      }[type];
    },
    add: addLine,
    remove: removeLine,
    edit: updateLine,
    getParams: getCreateLineParams,
    resultList: getLineCalResults,
    removeKey: "lineId",
    addKey: "line",
    resultListKey: "lineId"
  }, // 链路校准
  positioninfo: {
    list: getPositionCalInfos,
    add: addPosition,
    remove: removePositionCal,
    edit: updatePositionCal,
    getParams: getCreatePositionParams,
    resultList: getPositionCalResults,
    removeKey: "postionCalId",
    addKey: "postionCal",
    editKey: "positionCal",
    resultListKey: "positionId"
  } // 位置校准
} as Record<TypeKeys, ConfigParams>;
export const tableMap = {
  freqscope: [
    { label: "开始频率(MHz)", prop: "startFreq", type: "editable", editType: "input" },
    { label: "截止频率(MHz)", prop: "stopFreq", type: "editable", editType: "input" },
    { label: "步进", prop: "step", type: "editable", editType: "input" }
  ],
  antennafactor: [
    { label: "频率(MHz)", prop: "freq", type: "editable", editType: "input" },
    { label: "值", prop: "value", type: "editable", editType: "input" }
  ],
  lineinfo: [
    { label: "频率(MHz)", prop: "frequency" },
    { label: "损耗(dB)", prop: "pathLoss" }
  ],
  positioninfo: [
    { label: "频率(MHz)", prop: "frequency" },
    { label: "损耗(dB)", prop: "pathLoss" },
    { label: "测试点场强(dBuV/m)", prop: "tsPower" },
    { label: "被测点场强(dBuV/m)", prop: "utPower" }
  ]
};
export const chartMap = {
  antennafactor: {
    xKey: { name: "频率(MHz)", prop: "freq" },
    yKey: { name: "值", prop: "value" }
  },
  lineinfo: {
    xKey: { name: "频率(MHz)", prop: "frequency" },
    yKey: { name: "损耗(dB)", prop: "pathLoss" }
  },
  positioninfo: {
    xKey: { name: "频率(MHz)", prop: "frequency" },
    yKey: { name: "损耗(dB)", prop: "pathLoss" }
  }
};
